OBJS=serverMain.o openssl.o pthreadpool.o server.o parseMessage.o
CXXFLAGS=-std=c++11 -g -lpthread -I./Common -L./Common -lcommon  -llog4cxx -I/usr/include/mysql -lmysqlclient -lxml2 -I/usr/local/include/libxml2 -L/usr/local/libxml2 -lssl -lcrypto #-D_SPANPOOL
CXX=g++
ALL_TARGETS= serverMain

DESP=$(OBJS:%.o=.%.d)

all:debug $(ALL_TARGETS)

include $(DESP)

$(ALL_TARGETS):$(OBJS)
	$(CXX) $(OBJS) -o $@ $(CXXFLAGS) 

$(OBJS):%.o:%.cpp
	$(CXX) -c $< -o $@ $(CXXFLAGS)

$(DESP):.%.d:%.cpp 
	@$(CXX) -M $(CXXFLAGS) $< > $@

#如果前面的命令执行失败，执行exit 1
ALL_DIRS=./Common ./wwwroot/homepage/login/src  ./wwwroot/homepage/register/src
debug:
	@for dir in $(ALL_DIRS); \
		do \
		$(MAKE) -C $$dir || exit 1; \
		done


.PHONY:clean 
clean:subclean curclean

subclean:
	@for dir in $(ALL_DIRS); \
		do \
		$(MAKE) -C $$dir clean; \
		done

curclean:
	rm -rf $(ALL_TARGETS) $(OBJS)
	rm -rf .*.d

